﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace dsjsports
{
    /// <summary>
    /// Логика взаимодействия для TreeEvent.xaml
    /// </summary>
    public partial class TreeEvent : UserControl
    {
        public TreeEvent()
        {
            InitializeComponent();
            //RoutesVisualModel
        }

        private ObservableCollection<Route> routes = new ObservableCollection<Route>();
        public ObservableCollection<Route> Routes
        {
            get { return routes; }
        }

        public void Add(Route newRoute)
        {
            routes.Add(newRoute);
        }

        public void SetNewData(ObservableCollection<Route> Rout)
        {
            routes.Clear();
            routes = Rout;
            this.Update();
        }

        public void Update()
        {
            EventsTree.Items.Clear();
            foreach (Route r in routes)
            {
                //EventsTree.Items.Add(r);
                //TreeViewItem it = ((TreeViewItem)EventsTree.Items[EventsTree.Items.Count - 1]);
                //foreach (Protocol p in r.ProtocolCollection)
                //{
                //    it.Items.Add(p);
                //}
            }
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            Route r = new Route("1","2","3","4","5","6");
            r.Add(new Protocol("7", "8", "9"));
            r.ProtocolCollection[0].Add(new StaffAndResult(2));
            Add(r);
            Update();
        }
    }
}
